{include file="public/top" /}

<body>
<div class="x-body">
    <form class="layui-form">

        <div class="layui-form-item">
            <label for="name" class="layui-form-label">姓名</label>
            <div class="layui-input-inline">
                <input type="text" id="name" name="name" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label for="name" class="layui-form-label">手机号</label>
            <div class="layui-input-inline">
                <input type="text" id="mobile" name="mobile" lay-verify="phone" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label for="name" class="layui-form-label">密码</label>
            <div class="layui-input-inline">
                <input type="password" id="password" name="password" lay-verify="pass" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label for="name" class="layui-form-label">Email</label>
            <div class="layui-input-inline">
                <input type="text" id="email" name="email" lay-verify="email" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label for="name" class="layui-form-label">电话</label>
            <div class="layui-input-inline">
                <input type="text" id="telephone" name="telephone" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label for="name" class="layui-form-label">传真</label>
            <div class="layui-input-inline">
                <input type="text" id="fax" name="fax" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label for="name" class="layui-form-label">部门</label>
            <div class="layui-input-inline">
                <input type="text" id="branch" name="branch" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label for="name" class="layui-form-label">状态</label>
            <div class="layui-input-inline">
                <input type="radio" name="status" value="1" lay-skin="primary" title="启用" checked>
                <div class="layui-unselect layui-form-radio layui-form-radio" lay-skin="primary">
                    <span>启用</span><i class="layui-icon"></i>
                </div>

                <input type="radio" name="status" value="2" lay-skin="primary" title="停用">
                <div class="layui-unselect layui-form-radio" lay-skin="primary">
                    <span>停用</span><i class="layui-icon"></i>
                </div>

            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">
            </label>
            <button type="button"  class="layui-btn" lay-filter="add" lay-submit="">提交</button>
        </div>
    </form>
</div>
<script>
    layui.use(['form','layer'], function(){
        $ = layui.jquery;
        var form = layui.form ,layer = layui.layer;
        //自定义验证规则
        form.verify({
            pass: [/(.+){6,12}$/, '密码必须6到12位']
        });
        //监听提交
        form.on('submit(add)', function(data){
            $.post('', data.field, function(res) {
                var success = JSON.parse(res);
                if(success.code === 200){
                    layer.msg(success.msg, {
                        time: 1000, //不自动关闭
                        icon:6,
                        end:function () {
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                        }
                    });
                    return false;
                }else {
                    layer.msg(success.msg)
                }
            }, 'json');

        });


    });
</script>

</body>

</html>